package com.service.ljl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONObject;
import com.dao.ljl.invoicedao;
import com.dao.ljl.ododao;
import com.entity.Invoice;
import com.entity.Odo;

@Service
@Transactional(rollbackFor=ServiceException.class)
public class invoivceservice {
	@Autowired
	private ododao ododao;
	@Autowired
	private invoicedao invoicedao;
	
	public void add(Invoice invoice) {
		Odo odo=new Odo();
		odo=ododao.findOne(invoice.getOdo().getOdoId());
		invoice.setOdo(odo);
		invoicedao.save(invoice);
		
	}
	
	public void update(Map map) {
		Long id=JSONObject.parseObject(map.get("odoid").toString(),Long.class);
		Odo odo=ododao.findOne(id);
		Invoice invoice=JSONObject.parseObject(map.get("invoice").toString(),Invoice.class);
		invoice.setOdo(odo);
		invoicedao.save(invoice);
	}

}
